import {fetch} from './getData.js'

//export function centerInfo({params, usrId}) {
//params = params || {};
//params.url = `/v3/web/exp/queryCount/${usrId}`;
//return fetch(params);
//}

export function growthVal({params, usrId}) {
  params = params || {};
  params.url = `/v3/web/exp/maxExp/${usrId}`;
  return fetch(params);
}

export function growthList({params, currentPage = 1, perPage = 10, usrId, mchtName = ''}) {
  params = params || {};
  params.url = `/v3/web/exp/usrInMchtExp/${usrId}`;
  params.method = 'POST';
  params.data = {
    'aoData': JSON.stringify([{name:"iDisplayStart",value: currentPage},{name:"iDisplayLength","value": perPage}]),
    mchtName
  }
  return fetch(params);
}

export function ownBlockInfor({params, usrId}) {
  params = params || {};
  params.url = `/v3/web/block/${usrId}`;
  return fetch(params);
}

export function secretPwd({params, currentPage = 1, perPage = 10, dataPwd = '', usrId}) {
  params = params || {};
  params.url = '/v3/web/block/usrBlockTxn';
  params.method = 'POST';
  params.data = {
    'aoData': JSON.stringify([{name:"iDisplayStart",value: currentPage},{name:"iDisplayLength","value": perPage}]),
    dataPwd,
    usrId
  }
  return fetch(params);
}

export function deCodePwd({params, dataPwd, tradeNo, usrId}) {
  params = params || {};
  params.url = '/v3/web/block/usrBlockTxn';
  params.method = 'POST';
  params.data = {
    aoData: '',
    dataPwd,
    tradeNo,
    usrId
  }
  return fetch(params);
}

export function myCoupon({params, currentPage = 1, perPage = 5, type = '1', usrId}) {
  params = params || {};
  params.url = `/v3/web/myCoupon/my/${usrId}`;
  params.method = 'POST';
  params.data = {
    aoData: JSON.stringify([{name:"iDisplayStart",value: currentPage},{name:"iDisplayLength","value": perPage}]),
    type
  }
  return fetch(params);
}

export function shareMyCoupon({params, usrId, couponId, mchtId, num, shareId,shareType = ""}) {
  params = params || {};
  params.url = `/v3/web/business/share/${usrId}`;
  params.method = 'POST';
    params.data = {
        couponId,
        mchtId,
        num,
        shareId,
        shareType
    };
  return fetch(params);
}

export function searchFriend({params, usrId, friendName}) {
  params = params || {};
  params.url = `/v3/web/friend/findFriend/${usrId}`;
  params.method = 'POST';
  params.data = {
    friendName
  }
  return fetch(params);
}

export function delCouDeal({params, seqNo}) {
  params = params || {};
  params.url = `/v3/web/txn/${seqNo}`;
  params.method = 'DELETE';
  return fetch(params);
}

export function newUser({params, usrId, packId = 1}) {
  params = params || {};
  params.url = `/v4/web/checkPack/${usrId}/${packId}`;
  params.method = 'post';
  return fetch(params);
}

export function openBox({params, usrId, packId = 1, position}) {
  params = params || {};
  params.url = `/v4/web/use/${usrId}/${packId}`;
  params.method = 'post';
  params.data = position;
  return fetch(params);
}
export function useProp({params, usrId, num, propId, position}) {
  params = params || {};
  params.url = `/v4/web/prop/useProp/${usrId}`;
  params.method = 'post';
  params.data = {
    num, propId, position
  };
  return fetch(params);
}

export function totalProps({params, usrId, propId}) {
  params = params || {};
  params.url = `/v4/web/prop/${usrId}/${propId}`;
  params.method = 'post';
  params.data = {};
  return fetch(params);
}

export function giftList({params, usrId}) {
  params = params || {};
  params.url = `/v4/web/checkPack/myPackage/${usrId}`;
  params.method = 'post';
  return fetch(params);
}

/*****************  投票活动  *****************/
// 投票活动时间查询
export function ballotTime(id) {
  let params = {};
  params.url = `/v4/web/voteAct/queryWeChat/${id}` ;
  params.method = 'get';
  return fetch(params);
}

// 投票活动
export function queryBallot({currentPage = 1, perPage = 5, type = '', usrId, id}) {
  let params = {
    url: '/v4/web/voteCoupon/query',
    method: 'post',
    data: {
      aoData: JSON.stringify([{name:"iDisplayStart",value: currentPage},{name:"iDisplayLength","value": perPage}]),
      type,
      usrId,
      id
    }
  };
  return fetch(params);
}

// 参与投票
export function ballot({couponId, mchtId, usrId}) {
  let params = {};
  params.url = '/v4/web/voteCoupon/voteCount';
  params.method = 'post';
  params.data = {
    couponId,
    mchtId,
    usrId
  };
  return fetch(params);
}

// 参与投票
export function ballotStatue() {
  let params = {};
  params.url = '/v4/web/voteAct/enter';
  params.method = 'GET';
  return fetch(params);
}

// 投票结果查询
export function ballotResult({id, usrId}) {
  console.log(usrId);
  let params = {};
  params.url = '/v4/web/voteCoupon/detail';
  params.method = 'post';
  params.data = {
    id,
    usrId
  };
  return fetch(params);
}

// 投票结果前几名电子券查询
export function queryRankCoupon(id) {
  let params = {};
  params.url = `/v4/web/voteCoupon/award/${id}`;
  params.method = 'get';
  return fetch(params);
}

// 投票结果用户排名查询
export function queryRankUsr({id, awardNum}) {
  let params = {};
  params.url = '/v4/web/voteCoupon/queryUsrs';
  params.method = 'post';
  params.data = {
    id,
    awardNum
  };
  return fetch(params);
}

// 投票结果所有电子券查询
export function queryAllRankCoupon(id) {
  let params = {};
  params.url = `/v4/web/voteCoupon/queryCoupons/${id}`;
  params.method = 'get';
  return fetch(params);
}


/*****************  提现绑卡  *****************/
// 查卡信息
export function queryCard(usrId) {
  let params = {};
  params.url = '/v1/web/consumerwallet/cardInf';
  params.method = 'post';
  params.data = {
    usrId
  };
  return fetch(params);
}

// 绑卡
export function bindCard({accountName, bankCardNo, certType, certNo, usrId}) {
  let params = {};
  params.url = '/v1/web/consumerwallet/tiedCard';
  params.method = 'post';
  params.data = {
    accountName,
    bankCardNo,
    certType,
    certNo,
    usrId
  };
  return fetch(params);
}

// 发送短信验证码
export function sendMessage({mobilePhone, sendDateTime = "", usrId}) {
  let params = {};
  params.url = '/v1/web/sendSMS/draw';
  params.method = 'post';
  params.data = {
    mobilePhone,
    sendDateTime,
    usrId
  };
  return fetch(params);
}

// 短信验证绑卡
export function msgVerif({mobile, usrId, verifyCode}) {
  let params = {};
  params.url = '/v1/web/consumerwallet/synCard';
  params.method = 'post';
  params.data = {
    mobile,
    usrId,
    verifyCode
  };
  return fetch(params);
}

// 提现
export function withdrawals({usrId, amt}) {
  let params = {};
  params.url = '/v1/web/consumerwallet/withdrawals';
  params.method = 'post';
  params.data = {
    usrId, amt
  };
  return fetch(params);
}
